package com.xs.web;

import com.xs.pojo.Log;
import com.xs.service.LogSercice;
import com.xs.service.impl.LogSerciceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet("/conditionServlet")
public class ConditionServlet extends HttpServlet {
    LogSercice logSercice=new LogSerciceImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.setCharacterEncoding("utf-8");
        String user_name = request.getParameter("user_name");
        String sex = request.getParameter("sex");
        String phon = request.getParameter("phon");

        //封装
        Log log=new Log();
        log.setUser_name(user_name);
        log.setSex(sex);
        log.setPhon(phon);
        System.out.println(log);
        List<Log> logs = logSercice.selectCondition(log);
        System.out.println("根据输入的条件查询到的数据为："+logs);
        request.setAttribute("logs",logs);
        request.getRequestDispatcher("/booklog.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
